import { createRouter, createWebHistory } from "vue-router";
import AuthContainer from "../page/auth/index.vue";
import { SETTINGS_ROUTES } from "./settings/index";
import { DASHBOARD_ROUTES } from "./dashboard/index";
import { UNAUTH_ROUTES } from "./unAuth/";
import { ROLE_ROUTES } from "./role/index";
import { useRouterGuard } from "./guard";

export const ROUTES = [
  {
    path: "/",
    component: AuthContainer,
    children: [...DASHBOARD_ROUTES, ...SETTINGS_ROUTES, ...ROLE_ROUTES],
  },
  ...UNAUTH_ROUTES,
];

export const router = createRouter({
  history: createWebHistory(),
  routes: ROUTES,
});

if (import.meta.env.VITE_APP_ENV !== "dev") {
  // 路由守卫
  useRouterGuard(router);
}
